<template>
  <div class="common-page">
    <SearchForm
      :search-list="searchList"
      :search-params="searchParams"
      @search="onSearch"
      @reset="onReset"
    />
    <div class="table-box">
      <el-table
        v-loading="loading"
        height="100%"

        :data="tableData"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(255, 255, 255, 0.8)"
        @selection-change="onSelect"
      >
        <el-table-column v-for="item in columns" :key="item.prop" :prop="item.prop" :label="item.label" align="center" />
        <el-table-column label="项目状态">
          <template slot-scope="scope">
            <StatusTag :status="scope.row.status" />
          </template>
        </el-table-column>
        <el-table-column label="操作" fixed="right" width="140px">
          <template slot-scope="scope">
            <el-button
              v-if="scope.row.status >= 4 && scope.row.status != 6"
              type="primary"
              @click="onRead(scope.row)"
            >会议组织</el-button>
            <el-button
              type="primary"
              @click="onopen(scope.row)"
            >会议启动</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="page-box">
      <el-pagination
        background
        :current-page="pageNo"
        :page-sizes="pageSizes"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalSize"
        @size-change="changePageSize"
        @current-change="changePageNo"
      />
    </div>
    <Add ref="addFormRef" @get-page="initData" />
  </div>
</template>

<script>
import crud from '@/mixins/crud'
import Add from './add'
import { http } from '@/api'
const options1 = [
  { value: '1', name: '资规局' },
  { value: '2', name: '发改局' },
  { value: '3', name: '国企' }
]
export default {
  name: 'Index',
  components: {
    Add
  },
  mixins: [crud],
  data() {
    return {
      request: http.meeting_process,
      searchList: [
        {
          key: 'projectName',
          name: 'input',
          label: '项目名称'
        },
        {
          key: 'timeValue',
          name: 'datetime',
          valueFormat: 'yyyy-MM-dd',
          dateType: 'daterange',
          label: '时间'
        }
      ],
      searchParams: {
        meetingName: '',
        timeValue: []
      },
      columns: [
        { prop: 'projectName', label: '项目名称' },
        { prop: 'departName', label: '会议发起单位' },
        { prop: 'meetingStartTime', label: '会议时间' },
        { prop: 'meetingName', label: '会议室' }
      ],
      tableData: [

      ]
    }
  },
  methods: {
    formatTableData(data) {
      // data.forEach(el => {
      //   el.investorName = options1.find(item => item.value == el.investor)?.name
      // })
    },
    onRead(item) {
      this.$refs.addFormRef.open(item)
    },
    onopen(row) {
      this.$confirm('确认开启会议吗？', '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
      })
        .then(() => {
          this.request.startMeeting(row.id).then(res => {
            this.onSearch()
          })
        })
        .catch(() => {

        })
    },
  }
}
</script>

<style scoped lang="scss">
</style>
